package com.tang.chat.config;


import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

/**
 * @author tmh
 * @date 2024/5/5 16:12
 * @description
 */
public class GetHttpSessionConfig extends ServerEndpointConfig.Configurator {
    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        //获取HttpSession对象
        HttpSession httpSession = (HttpSession) request.getHttpSession();
        System.out.println(httpSession.getAttribute("user"));
        System.out.println(HttpSession.class.getName());
        System.out.println(sec);
        //将HttpSession对象保存到sec里面
        sec.getUserProperties().put(HttpSession.class.getName(),httpSession);
    }
}
